<extend name="Base/common" />
<block name="body">
	<!--导航引用-->
	<include file="Public/nav" />
	<footer class="ui-footer ui-footer-stable ui-btn-group ui-whitespace ui-border-t">
	    <a href="javascript:void(0);" class="ui-btn-lg ui-btn-danger" id="js-submit-order">确定订单</a>
	</footer>
	<section class="ui-container">
		<form id="js-trolly-form" action="{:U('Order/create_order')}" method="post">
			<div class="ui-confirm-order">
				<h5>收货人信息</h5>
				<ul class="ui-list ui-list-link ui-border-tb">
				    <li class="ui-border-t user_address">
				    	<input type="hidden" id="address_id" name="take_id" value="{$data.id|default=0}" autocomplete="off">
			    		<div class="ui-list-info">
			    			<empty name="data.sname">
				    			<p class="ui-nowrap" style="color:red;">您还未添加任何默认地址，请先添加地址！</p>
				    		<else />
				    			<h4 class="ui-nowrap"><b>收货人:{$data.sname}</b><br /><small>电话:{$data.phone}</small></h4>
					            <p class="ui-nowrap">收货地址:{$data.pro_name}&nbsp;{$data.city_name}&nbsp;{$data.area_name}&nbsp;{$data.address}</p>
				    		</empty>
				    	</div>
				    </li>
				</ul>
				<h5>结算明细</h5>
		        <ul class="ui-list ui-list-one ui-border-t ui-whitespace ui-list-order-detail">
				    <li class="ui-border-t">
			            <h4 class="ui-nowrap">商品数量</h4>
			            <p class="ui-txt-info" style="color:black;">{$data.goods_num}件</p>
				    </li>
				    <li class="ui-border-t">
			            <h4 class="ui-nowrap">商品金额</h4>
			            <p class="ui-txt-info" style="color:black;">￥{$data.pricenum}</p>
				    </li>
				    <li class="ui-border-t">
			            <h4 class="ui-nowrap">邮费</h4>
			            <p class="ui-txt-info" style="color:black;">￥<eq name="row.is_patch" value="1">{$data.fare|default=0}<else />0</eq></p>
				    </li>
				    <li class="ui-border-t">
			            <h4 class="ui-nowrap" style="font-weight: bold;font-size: 14px;">应付总额</h4>
			            <p class="ui-txt-info" style="font-weight: bold;font-size: 14px;">￥{$data.priceAll}</p>
			            <input type="hidden" name="pock_money" value="{$data.priceAll}" autocomplete="off"><!--实付金额-->
				    </li>
				</ul>
				<h5>订单信息</h5>
				<ul class="ui-list-goods-cart ui-whitespace ui-border-tb">
					
					<li class="ui-tiled ui-border-b">
						<input type="hidden" name="cart_id" value="{$row.cart_id}" autocomplete="off">
						<div class="ui-list-goods-img">
				            <img src="{$row.picture||get_cover='path'}" width="50" height="50"/>
				        </div>
				        <div class="ui-list-goods-info">
				        	<h5>{$row.name}</h5>
				        	<p class="ui-goods-size-color">
			        			<span>数量：{$row.num}</span><br />
				        	</p>
				        </div>
				        <div class="ui-list-goods-price">
				        	<p class="price">
				        		<b>￥{$row.price}</b>
				        		<del>{$row.shop_price}</del>
				        	</p>
				        </div>
					</li>
				</ul>
				<h5>订单留言</h5>
				<div class="ui-message-textarea">
		            <textarea placeholder="订单留言，最多支持100个字符" id="msg" name="msg"></textarea>
		        </div>
		        
	        </div>
    	</form>
	</section>
</block>
<block name="script">
	<script type="text/javascript">
		$('.user_address').tap(function(){
			window.location.href = "{:U('Member/userManager', array('order_type' => 'yes'))}";
		});

		var el = '';
		$('#js-submit-order').tap(function(){
        	var take_id = $('#address_id').val();
        	if(take_id == 0){
       //  		$.tips({
			    //     content:'您还未添加任何默认地址，请先添加地址！',
			    //     stayTime:2000,
			    //     type:"success"
			    // });
			    var dia=$.dialog({
					        title:'温馨提示',
					        content:'系统检测你还没有收货地址！',
					        button:["取消", "现在添加"]
					    });

				    dia.on("dialog:action",function(e){
				        if( e.index == 1 ){
				        	//添加收货地址
				        	window.location.href = "{:U('Member/userManager', array('order_type' => 'yes'))}";
				        }
				    });
				    dia.on("dialog:hide",function(e){
				        console.log("dialog hide")
				    });
        		return false;
        	}
        	$.ajax({
        		url: "{:U('Order/create_order')}",
        		type: 'POST',
        		data: $('#js-trolly-form').serialize(),
        		dataType: 'json',
        		beforeSend: function(){
					el = $.loading({content:'加载中...'})
				},
        		success: function(r){
        			el.loading("hide");
        			if(r.status){
        				window.location.href = r.url;
        			}else{
        				$.tips({
					        content: r.info,
					        stayTime:2000,
					        type:"success"
					    });
        			}
        		}
        	});
        });
	</script>
</block>